home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-15.z / lispref.info-15
Encoding:
GNU Info File  |  1998-05-21  |  48.7 KB  |  1,152 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Minibuffer History,  Next: Completion,  Prev: Object from Minibuffer,  Up: Minibuffers
  48.  
  49. Minibuffer History
  50. ==================
  51.  
  52.    A "minibuffer history list" records previous minibuffer inputs so
  53. the user can reuse them conveniently.  A history list is actually a
  54. symbol, not a list; it is a variable whose value is a list of strings
  55. (previous inputs), most recent first.
  56.  
  57.    There are many separate history lists, used for different kinds of
  58. inputs.  It's the Lisp programmer's job to specify the right history
  59. list for each use of the minibuffer.
  60.  
  61.    The basic minibuffer input functions `read-from-minibuffer' and
  62. `completing-read' both accept an optional argument named HIST which is
  63. how you specify the history list.  Here are the possible values:
  64.  
  65. VARIABLE
  66.      Use VARIABLE (a symbol) as the history list.
  67.  
  68. (VARIABLE . STARTPOS)
  69.      Use VARIABLE (a symbol) as the history list, and assume that the
  70.      initial history position is STARTPOS (an integer, counting from
  71.      zero which specifies the most recent element of the history).
  72.  
  73.      If you specify STARTPOS, then you should also specify that element
  74.      of the history as the initial minibuffer contents, for consistency.
  75.  
  76.    If you don't specify HIST, then the default history list
  77. `minibuffer-history' is used.  For other standard history lists, see
  78. below.  You can also create your own history list variable; just
  79. initialize it to `nil' before the first use.
  80.  
  81.    Both `read-from-minibuffer' and `completing-read' add new elements
  82. to the history list automatically, and provide commands to allow the
  83. user to reuse items on the list.  The only thing your program needs to
  84. do to use a history list is to initialize it and to pass its name to
  85. the input functions when you wish.  But it is safe to modify the list
  86. by hand when the minibuffer input functions are not using it.
  87.  
  88.  - Variable: minibuffer-history
  89.      The default history list for minibuffer history input.
  90.  
  91.  - Variable: query-replace-history
  92.      A history list for arguments to `query-replace' (and similar
  93.      arguments to other commands).
  94.  
  95.  - Variable: file-name-history
  96.      A history list for file name arguments.
  97.  
  98.  - Variable: regexp-history
  99.      A history list for regular expression arguments.
  100.  
  101.  - Variable: extended-command-history
  102.      A history list for arguments that are names of extended commands.
  103.  
  104.  - Variable: shell-command-history
  105.      A history list for arguments that are shell commands.
  106.  
  107.  - Variable: read-expression-history
  108.      A history list for arguments that are Lisp expressions to evaluate.
  109.  
  110.  - Variable: Info-minibuffer-history
  111.      A history list for Info mode's minibuffer.
  112.  
  113.  - Variable: Manual-page-minibuffer-history
  114.      A history list for `manual-entry'.
  115.  
  116.    There are many other minibuffer history lists, defined by various
  117. libraries.  An `M-x apropos' search for `history' should prove fruitful
  118. in discovering them.
  119.  
  120. 
  121. File: lispref.info,  Node: Completion,  Next: Yes-or-No Queries,  Prev: Minibuffer History,  Up: Minibuffers
  122.  
  123. Completion
  124. ==========
  125.  
  126.    "Completion" is a feature that fills in the rest of a name starting
  127. from an abbreviation for it.  Completion works by comparing the user's
  128. input against a list of valid names and determining how much of the
  129. name is determined uniquely by what the user has typed.  For example,
  130. when you type `C-x b' (`switch-to-buffer') and then type the first few
  131. letters of the name of the buffer to which you wish to switch, and then
  132. type <TAB> (`minibuffer-complete'), Emacs extends the name as far as it
  133. can.
  134.  
  135.    Standard XEmacs commands offer completion for names of symbols,
  136. files, buffers, and processes; with the functions in this section, you
  137. can implement completion for other kinds of names.
  138.  
  139.    The `try-completion' function is the basic primitive for completion:
  140. it returns the longest determined completion of a given initial string,
  141. with a given set of strings to match against.
  142.  
  143.    The function `completing-read' provides a higher-level interface for
  144. completion.  A call to `completing-read' specifies how to determine the
  145. list of valid names.  The function then activates the minibuffer with a
  146. local keymap that binds a few keys to commands useful for completion.
  147. Other functions provide convenient simple interfaces for reading
  148. certain kinds of names with completion.
  149.  
  150. * Menu:
  151.  
  152. * Basic Completion::       Low-level functions for completing strings.
  153.                              (These are too low level to use the minibuffer.)
  154. * Minibuffer Completion::  Invoking the minibuffer with completion.
  155. * Completion Commands::    Minibuffer commands that do completion.
  156. * High-Level Completion::  Convenient special cases of completion
  157.                              (reading buffer name, file name, etc.)
  158. * Reading File Names::     Using completion to read file names.
  159. * Programmed Completion::  Finding the completions for a given file name.
  160.  
  161. 
  162. File: lispref.info,  Node: Basic Completion,  Next: Minibuffer Completion,  Up: Completion
  163.  
  164. Basic Completion Functions
  165. --------------------------
  166.  
  167.    The two functions `try-completion' and `all-completions' have
  168. nothing in themselves to do with minibuffers.  We describe them in this
  169. chapter so as to keep them near the higher-level completion features
  170. that do use the minibuffer.
  171.  
  172.  - Function: try-completion STRING COLLECTION &optional PREDICATE
  173.      This function returns the longest common substring of all possible
  174.      completions of STRING in COLLECTION.  The value of COLLECTION must
  175.      be an alist, an obarray, or a function that implements a virtual
  176.      set of strings (see below).
  177.  
  178.      Completion compares STRING against each of the permissible
  179.      completions specified by COLLECTION; if the beginning of the
  180.      permissible completion equals STRING, it matches.  If no
  181.      permissible completions match, `try-completion' returns `nil'.  If
  182.      only one permissible completion matches, and the match is exact,
  183.      then `try-completion' returns `t'.  Otherwise, the value is the
  184.      longest initial sequence common to all the permissible completions
  185.      that match.
  186.  
  187.      If COLLECTION is an alist (*note Association Lists::.), the CARs
  188.      of the alist elements form the set of permissible completions.
  189.  
  190.      If COLLECTION is an obarray (*note Creating Symbols::.), the names
  191.      of all symbols in the obarray form the set of permissible
  192.      completions.  The global variable `obarray' holds an obarray
  193.      containing the names of all interned Lisp symbols.
  194.  
  195.      Note that the only valid way to make a new obarray is to create it
  196.      empty and then add symbols to it one by one using `intern'.  Also,
  197.      you cannot intern a given symbol in more than one obarray.
  198.  
  199.      If the argument PREDICATE is non-`nil', then it must be a function
  200.      of one argument.  It is used to test each possible match, and the
  201.      match is accepted only if PREDICATE returns non-`nil'.  The
  202.      argument given to PREDICATE is either a cons cell from the alist
  203.      (the CAR of which is a string) or else it is a symbol (*not* a
  204.      symbol name) from the obarray.
  205.  
  206.      You can also use a symbol that is a function as COLLECTION.  Then
  207.      the function is solely responsible for performing completion;
  208.      `try-completion' returns whatever this function returns.  The
  209.      function is called with three arguments: STRING, PREDICATE and
  210.      `nil'.  (The reason for the third argument is so that the same
  211.      function can be used in `all-completions' and do the appropriate
  212.      thing in either case.)  *Note Programmed Completion::.
  213.  
  214.      In the first of the following examples, the string `foo' is
  215.      matched by three of the alist CARs.  All of the matches begin with
  216.      the characters `fooba', so that is the result.  In the second
  217.      example, there is only one possible match, and it is exact, so the
  218.      value is `t'.
  219.  
  220.           (try-completion
  221.            "foo"
  222.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4)))
  223.                => "fooba"
  224.  
  225.           (try-completion "foo" '(("barfoo" 2) ("foo" 3)))
  226.                => t
  227.  
  228.      In the following example, numerous symbols begin with the
  229.      characters `forw', and all of them begin with the word `forward'.
  230.      In most of the symbols, this is followed with a `-', but not in
  231.      all, so no more than `forward' can be completed.
  232.  
  233.           (try-completion "forw" obarray)
  234.                => "forward"
  235.  
  236.      Finally, in the following example, only two of the three possible
  237.      matches pass the predicate `test' (the string `foobaz' is too
  238.      short).  Both of those begin with the string `foobar'.
  239.  
  240.           (defun test (s)
  241.             (> (length (car s)) 6))
  242.                => test
  243.  
  244.           (try-completion
  245.            "foo"
  246.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  247.            'test)
  248.                => "foobar"
  249.  
  250.  - Function: all-completions STRING COLLECTION &optional PREDICATE
  251.           NOSPACE
  252.      This function returns a list of all possible completions of
  253.      STRING.  The parameters to this function are the same as to
  254.      `try-completion'.
  255.  
  256.      If COLLECTION is a function, it is called with three arguments:
  257.      STRING, PREDICATE and `t'; then `all-completions' returns whatever
  258.      the function returns.  *Note Programmed Completion::.
  259.  
  260.      If NOSPACE is non-`nil', completions that start with a space are
  261.      ignored unless STRING also starts with a space.
  262.  
  263.      Here is an example, using the function `test' shown in the example
  264.      for `try-completion':
  265.  
  266.           (defun test (s)
  267.             (> (length (car s)) 6))
  268.                => test
  269.  
  270.           (all-completions
  271.            "foo"
  272.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  273.            'test)
  274.                => ("foobar1" "foobar2")
  275.  
  276.  - Variable: completion-ignore-case
  277.      If the value of this variable is non-`nil', XEmacs does not
  278.      consider case significant in completion.
  279.  
  280. 
  281. File: lispref.info,  Node: Minibuffer Completion,  Next: Completion Commands,  Prev: Basic Completion,  Up: Completion
  282.  
  283. Completion and the Minibuffer
  284. -----------------------------
  285.  
  286.    This section describes the basic interface for reading from the
  287. minibuffer with completion.
  288.  
  289.  - Function: completing-read PROMPT COLLECTION &optional PREDICATE
  290.           REQUIRE-MATCH INITIAL HIST
  291.      This function reads a string in the minibuffer, assisting the user
  292.      by providing completion.  It activates the minibuffer with prompt
  293.      PROMPT, which must be a string.  If INITIAL is non-`nil',
  294.      `completing-read' inserts it into the minibuffer as part of the
  295.      input.  Then it allows the user to edit the input, providing
  296.      several commands to attempt completion.
  297.  
  298.      The actual completion is done by passing COLLECTION and PREDICATE
  299.      to the function `try-completion'.  This happens in certain
  300.      commands bound in the local keymaps used for completion.
  301.  
  302.      If REQUIRE-MATCH is `t', the usual minibuffer exit commands won't
  303.      exit unless the input completes to an element of COLLECTION.  If
  304.      REQUIRE-MATCH is neither `nil' nor `t', then the exit commands
  305.      won't exit unless the input typed is itself an element of
  306.      COLLECTION.  If REQUIRE-MATCH is `nil', the exit commands work
  307.      regardless of the input in the minibuffer.
  308.  
  309.      The user can exit with null input by typing <RET> with an empty
  310.      minibuffer.  Then `completing-read' returns `nil'.  This is how
  311.      the user requests whatever default the command uses for the value
  312.      being read.  The user can return using <RET> in this way regardless
  313.      of the value of REQUIRE-MATCH.
  314.  
  315.      The function `completing-read' works by calling `read-minibuffer'.
  316.      It uses `minibuffer-local-completion-map' as the keymap if
  317.      REQUIRE-MATCH is `nil', and uses `minibuffer-local-must-match-map'
  318.      if REQUIRE-MATCH is non-`nil'.  *Note Completion Commands::.
  319.  
  320.      The argument HIST specifies which history list variable to use for
  321.      saving the input and for minibuffer history commands.  It defaults
  322.      to `minibuffer-history'.  *Note Minibuffer History::.
  323.  
  324.      Completion ignores case when comparing the input against the
  325.      possible matches, if the built-in variable
  326.      `completion-ignore-case' is non-`nil'.  *Note Basic Completion::.
  327.  
  328.      Here's an example of using `completing-read':
  329.  
  330.           (completing-read
  331.            "Complete a foo: "
  332.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  333.            nil t "fo")
  334.  
  335.           ;; After evaluation of the preceding expression,
  336.           ;;   the following appears in the minibuffer:
  337.           
  338.           ---------- Buffer: Minibuffer ----------
  339.           Complete a foo: fo-!-
  340.           ---------- Buffer: Minibuffer ----------
  341.  
  342.      If the user then types `<DEL> <DEL> b <RET>', `completing-read'
  343.      returns `barfoo'.
  344.  
  345.      The `completing-read' function binds three variables to pass
  346.      information to the commands that actually do completion.  These
  347.      variables are `minibuffer-completion-table',
  348.      `minibuffer-completion-predicate' and
  349.      `minibuffer-completion-confirm'.  For more information about them,
  350.      see *Note Completion Commands::.
  351.  
  352. 
  353. File: lispref.info,  Node: Completion Commands,  Next: High-Level Completion,  Prev: Minibuffer Completion,  Up: Completion
  354.  
  355. Minibuffer Commands That Do Completion
  356. --------------------------------------
  357.  
  358.    This section describes the keymaps, commands and user options used in
  359. the minibuffer to do completion.
  360.  
  361.  - Variable: minibuffer-local-completion-map
  362.      `completing-read' uses this value as the local keymap when an
  363.      exact match of one of the completions is not required.  By
  364.      default, this keymap makes the following bindings:
  365.  
  366.     `?'
  367.           `minibuffer-completion-help'
  368.  
  369.     <SPC>
  370.           `minibuffer-complete-word'
  371.  
  372.     <TAB>
  373.           `minibuffer-complete'
  374.  
  375.      with other characters bound as in `minibuffer-local-map' (*note
  376.      Text from Minibuffer::.).
  377.  
  378.  - Variable: minibuffer-local-must-match-map
  379.      `completing-read' uses this value as the local keymap when an
  380.      exact match of one of the completions is required.  Therefore, no
  381.      keys are bound to `exit-minibuffer', the command that exits the
  382.      minibuffer unconditionally.  By default, this keymap makes the
  383.      following bindings:
  384.  
  385.     `?'
  386.           `minibuffer-completion-help'
  387.  
  388.     <SPC>
  389.           `minibuffer-complete-word'
  390.  
  391.     <TAB>
  392.           `minibuffer-complete'
  393.  
  394.     <LFD>
  395.           `minibuffer-complete-and-exit'
  396.  
  397.     <RET>
  398.           `minibuffer-complete-and-exit'
  399.  
  400.      with other characters bound as in `minibuffer-local-map'.
  401.  
  402.  - Variable: minibuffer-completion-table
  403.      The value of this variable is the alist or obarray used for
  404.      completion in the minibuffer.  This is the global variable that
  405.      contains what `completing-read' passes to `try-completion'.  It is
  406.      used by minibuffer completion commands such as
  407.      `minibuffer-complete-word'.
  408.  
  409.  - Variable: minibuffer-completion-predicate
  410.      This variable's value is the predicate that `completing-read'
  411.      passes to `try-completion'.  The variable is also used by the other
  412.      minibuffer completion functions.
  413.  
  414.  - Command: minibuffer-complete-word
  415.      This function completes the minibuffer contents by at most a single
  416.      word.  Even if the minibuffer contents have only one completion,
  417.      `minibuffer-complete-word' does not add any characters beyond the
  418.      first character that is not a word constituent.  *Note Syntax
  419.      Tables::.
  420.  
  421.  - Command: minibuffer-complete
  422.      This function completes the minibuffer contents as far as possible.
  423.  
  424.  - Command: minibuffer-complete-and-exit
  425.      This function completes the minibuffer contents, and exits if
  426.      confirmation is not required, i.e., if
  427.      `minibuffer-completion-confirm' is non-`nil'.  If confirmation
  428.      *is* required, it is given by repeating this command
  429.      immediately--the command is programmed to work without confirmation
  430.      when run twice in succession.
  431.  
  432.  - Variable: minibuffer-completion-confirm
  433.      When the value of this variable is non-`nil', XEmacs asks for
  434.      confirmation of a completion before exiting the minibuffer.  The
  435.      function `minibuffer-complete-and-exit' checks the value of this
  436.      variable before it exits.
  437.  
  438.  - Command: minibuffer-completion-help
  439.      This function creates a list of the possible completions of the
  440.      current minibuffer contents.  It works by calling `all-completions'
  441.      using the value of the variable `minibuffer-completion-table' as
  442.      the COLLECTION argument, and the value of
  443.      `minibuffer-completion-predicate' as the PREDICATE argument.  The
  444.      list of completions is displayed as text in a buffer named
  445.      `*Completions*'.
  446.  
  447.  - Function: display-completion-list COMPLETIONS
  448.      This function displays COMPLETIONS to the stream in
  449.      `standard-output', usually a buffer.  (*Note Read and Print::, for
  450.      more information about streams.)  The argument COMPLETIONS is
  451.      normally a list of completions just returned by `all-completions',
  452.      but it does not have to be.  Each element may be a symbol or a
  453.      string, either of which is simply printed, or a list of two
  454.      strings, which is printed as if the strings were concatenated.
  455.  
  456.      This function is called by `minibuffer-completion-help'.  The most
  457.      common way to use it is together with
  458.      `with-output-to-temp-buffer', like this:
  459.  
  460.           (with-output-to-temp-buffer "*Completions*"
  461.             (display-completion-list
  462.               (all-completions (buffer-string) my-alist)))
  463.  
  464.  - User Option: completion-auto-help
  465.      If this variable is non-`nil', the completion commands
  466.      automatically display a list of possible completions whenever
  467.      nothing can be completed because the next character is not
  468.      uniquely determined.
  469.  
  470. 
  471. File: lispref.info,  Node: High-Level Completion,  Next: Reading File Names,  Prev: Completion Commands,  Up: Completion
  472.  
  473. High-Level Completion  Functions
  474. --------------------------------
  475.  
  476.    This section describes the higher-level convenient functions for
  477. reading certain sorts of names with completion.
  478.  
  479.    In most cases, you should not call these functions in the middle of a
  480. Lisp function.  When possible, do all minibuffer input as part of
  481. reading the arguments for a command, in the `interactive' spec.  *Note
  482. Defining Commands::.
  483.  
  484.  - Function: read-buffer PROMPT &optional DEFAULT EXISTING
  485.      This function reads the name of a buffer and returns it as a
  486.      string.  The argument DEFAULT is the default name to use, the
  487.      value to return if the user exits with an empty minibuffer.  If
  488.      non-`nil', it should be a string or a buffer.  It is mentioned in
  489.      the prompt, but is not inserted in the minibuffer as initial input.
  490.  
  491.      If EXISTING is non-`nil', then the name specified must be that of
  492.      an existing buffer.  The usual commands to exit the minibuffer do
  493.      not exit if the text is not valid, and <RET> does completion to
  494.      attempt to find a valid name.  (However, DEFAULT is not checked
  495.      for validity; it is returned, whatever it is, if the user exits
  496.      with the minibuffer empty.)
  497.  
  498.      In the following example, the user enters `minibuffer.t', and then
  499.      types <RET>.  The argument EXISTING is `t', and the only buffer
  500.      name starting with the given input is `minibuffer.texi', so that
  501.      name is the value.
  502.  
  503.           (read-buffer "Buffer name? " "foo" t)
  504.           ;; After evaluation of the preceding expression,
  505.           ;;   the following prompt appears,
  506.           ;;   with an empty minibuffer:
  507.           
  508.           ---------- Buffer: Minibuffer ----------
  509.           Buffer name? (default foo) -!-
  510.           ---------- Buffer: Minibuffer ----------
  511.           
  512.           ;; The user types `minibuffer.t <RET>'.
  513.                => "minibuffer.texi"
  514.  
  515.  - Function: read-command PROMPT
  516.      This function reads the name of a command and returns it as a Lisp
  517.      symbol.  The argument PROMPT is used as in `read-from-minibuffer'.
  518.      Recall that a command is anything for which `commandp' returns
  519.      `t', and a command name is a symbol for which `commandp' returns
  520.      `t'.  *Note Interactive Call::.
  521.  
  522.           (read-command "Command name? ")
  523.           
  524.           ;; After evaluation of the preceding expression,
  525.           ;;   the following prompt appears with an empty minibuffer:
  526.           
  527.           ---------- Buffer: Minibuffer ----------
  528.           Command name?
  529.           ---------- Buffer: Minibuffer ----------
  530.  
  531.      If the user types `forward-c <RET>', then this function returns
  532.      `forward-char'.
  533.  
  534.      The `read-command' function is a simplified interface to the
  535.      function `completing-read'.  It uses the variable `obarray' so as
  536.      to complete in the set of extant Lisp symbols, and it uses the
  537.      `commandp' predicate so as to accept only command names:
  538.  
  539.           (read-command PROMPT)
  540.           ==
  541.           (intern (completing-read PROMPT obarray
  542.                                    'commandp t nil))
  543.  
  544.  - Function: read-variable PROMPT
  545.      This function reads the name of a user variable and returns it as a
  546.      symbol.
  547.  
  548.           (read-variable "Variable name? ")
  549.           
  550.           ;; After evaluation of the preceding expression,
  551.           ;;   the following prompt appears,
  552.           ;;   with an empty minibuffer:
  553.           
  554.           ---------- Buffer: Minibuffer ----------
  555.           Variable name? -!-
  556.           ---------- Buffer: Minibuffer ----------
  557.  
  558.      If the user then types `fill-p <RET>', `read-variable' returns
  559.      `fill-prefix'.
  560.  
  561.      This function is similar to `read-command', but uses the predicate
  562.      `user-variable-p' instead of `commandp':
  563.  
  564.           (read-variable PROMPT)
  565.           ==
  566.           (intern
  567.            (completing-read PROMPT obarray
  568.                             'user-variable-p t nil))
  569.  
  570. 
  571. File: lispref.info,  Node: Reading File Names,  Next: Programmed Completion,  Prev: High-Level Completion,  Up: Completion
  572.  
  573. Reading File Names
  574. ------------------
  575.  
  576.    Here is another high-level completion function, designed for reading
  577. a file name.  It provides special features including automatic insertion
  578. of the default directory.
  579.  
  580.  - Function: read-file-name PROMPT &optional DIRECTORY DEFAULT EXISTING
  581.           INITIAL
  582.      This function reads a file name in the minibuffer, prompting with
  583.      PROMPT and providing completion.  If DEFAULT is non-`nil', then
  584.      the function returns DEFAULT if the user just types <RET>.
  585.      DEFAULT is not checked for validity; it is returned, whatever it
  586.      is, if the user exits with the minibuffer empty.
  587.  
  588.      If EXISTING is non-`nil', then the user must specify the name of
  589.      an existing file; <RET> performs completion to make the name valid
  590.      if possible, and then refuses to exit if it is not valid.  If the
  591.      value of EXISTING is neither `nil' nor `t', then <RET> also
  592.      requires confirmation after completion.  If EXISTING is `nil',
  593.      then the name of a nonexistent file is acceptable.
  594.  
  595.      The argument DIRECTORY specifies the directory to use for
  596.      completion of relative file names.  If `insert-default-directory'
  597.      is non-`nil', DIRECTORY is also inserted in the minibuffer as
  598.      initial input.  It defaults to the current buffer's value of
  599.      `default-directory'.
  600.  
  601.      If you specify INITIAL, that is an initial file name to insert in
  602.      the buffer (after with DIRECTORY, if that is inserted).  In this
  603.      case, point goes at the beginning of INITIAL.  The default for
  604.      INITIAL is `nil'--don't insert any file name.  To see what INITIAL
  605.      does, try the command `C-x C-v'.
  606.  
  607.      Here is an example:
  608.  
  609.           (read-file-name "The file is ")
  610.           
  611.           ;; After evaluation of the preceding expression,
  612.           ;;   the following appears in the minibuffer:
  613.           
  614.           ---------- Buffer: Minibuffer ----------
  615.           The file is /gp/gnu/elisp/-!-
  616.           ---------- Buffer: Minibuffer ----------
  617.  
  618.      Typing `manual <TAB>' results in the following:
  619.  
  620.           ---------- Buffer: Minibuffer ----------
  621.           The file is /gp/gnu/elisp/manual.texi-!-
  622.           ---------- Buffer: Minibuffer ----------
  623.  
  624.      If the user types <RET>, `read-file-name' returns the file name as
  625.      the string `"/gp/gnu/elisp/manual.texi"'.
  626.  
  627.  - User Option: insert-default-directory
  628.      This variable is used by `read-file-name'.  Its value controls
  629.      whether `read-file-name' starts by placing the name of the default
  630.      directory in the minibuffer, plus the initial file name if any.
  631.      If the value of this variable is `nil', then `read-file-name' does
  632.      not place any initial input in the minibuffer (unless you specify
  633.      initial input with the INITIAL argument).  In that case, the
  634.      default directory is still used for completion of relative file
  635.      names, but is not displayed.
  636.  
  637.      For example:
  638.  
  639.           ;; Here the minibuffer starts out with the default directory.
  640.           (let ((insert-default-directory t))
  641.             (read-file-name "The file is "))
  642.           
  643.           ---------- Buffer: Minibuffer ----------
  644.           The file is ~lewis/manual/-!-
  645.           ---------- Buffer: Minibuffer ----------
  646.           
  647.           ;; Here the minibuffer is empty and only the prompt
  648.           ;;   appears on its line.
  649.           (let ((insert-default-directory nil))
  650.             (read-file-name "The file is "))
  651.           
  652.           ---------- Buffer: Minibuffer ----------
  653.           The file is -!-
  654.           ---------- Buffer: Minibuffer ----------
  655.  
  656. 
  657. File: lispref.info,  Node: Programmed Completion,  Prev: Reading File Names,  Up: Completion
  658.  
  659. Programmed Completion
  660. ---------------------
  661.  
  662.    Sometimes it is not possible to create an alist or an obarray
  663. containing all the intended possible completions.  In such a case, you
  664. can supply your own function to compute the completion of a given
  665. string.  This is called "programmed completion".
  666.  
  667.    To use this feature, pass a symbol with a function definition as the
  668. COLLECTION argument to `completing-read'.  The function
  669. `completing-read' arranges to pass your completion function along to
  670. `try-completion' and `all-completions', which will then let your
  671. function do all the work.
  672.  
  673.    The completion function should accept three arguments:
  674.  
  675.    * The string to be completed.
  676.  
  677.    * The predicate function to filter possible matches, or `nil' if
  678.      none.  Your function should call the predicate for each possible
  679.      match, and ignore the possible match if the predicate returns
  680.      `nil'.
  681.  
  682.    * A flag specifying the type of operation.
  683.  
  684.    There are three flag values for three operations:
  685.  
  686.    * `nil' specifies `try-completion'.  The completion function should
  687.      return the completion of the specified string, or `t' if the
  688.      string is an exact match already, or `nil' if the string matches no
  689.      possibility.
  690.  
  691.    * `t' specifies `all-completions'.  The completion function should
  692.      return a list of all possible completions of the specified string.
  693.  
  694.    * `lambda' specifies a test for an exact match.  The completion
  695.      function should return `t' if the specified string is an exact
  696.      match for some possibility; `nil' otherwise.
  697.  
  698.    It would be consistent and clean for completion functions to allow
  699. lambda expressions (lists that are functions) as well as function
  700. symbols as COLLECTION, but this is impossible.  Lists as completion
  701. tables are already assigned another meaning--as alists.  It would be
  702. unreliable to fail to handle an alist normally because it is also a
  703. possible function.  So you must arrange for any function you wish to
  704. use for completion to be encapsulated in a symbol.
  705.  
  706.    Emacs uses programmed completion when completing file names.  *Note
  707. File Name Completion::.
  708.  
  709. 
  710. File: lispref.info,  Node: Yes-or-No Queries,  Next: Multiple Queries,  Prev: Completion,  Up: Minibuffers
  711.  
  712. Yes-or-No Queries
  713. =================
  714.  
  715.    This section describes functions used to ask the user a yes-or-no
  716. question.  The function `y-or-n-p' can be answered with a single
  717. character; it is useful for questions where an inadvertent wrong answer
  718. will not have serious consequences.  `yes-or-no-p' is suitable for more
  719. momentous questions, since it requires three or four characters to
  720. answer.  Variations of these functions can be used to ask a yes-or-no
  721. question using a dialog box, or optionally using one.
  722.  
  723.    If either of these functions is called in a command that was invoked
  724. using the mouse, then it uses a dialog box or pop-up menu to ask the
  725. question.  Otherwise, it uses keyboard input.
  726.  
  727.    Strictly speaking, `yes-or-no-p' uses the minibuffer and `y-or-n-p'
  728. does not; but it seems best to describe them together.
  729.  
  730.  - Function: y-or-n-p PROMPT
  731.      This function asks the user a question, expecting input in the echo
  732.      area.  It returns `t' if the user types `y', `nil' if the user
  733.      types `n'.  This function also accepts <SPC> to mean yes and <DEL>
  734.      to mean no.  It accepts `C-]' to mean "quit", like `C-g', because
  735.      the question might look like a minibuffer and for that reason the
  736.      user might try to use `C-]' to get out.  The answer is a single
  737.      character, with no <RET> needed to terminate it.  Upper and lower
  738.      case are equivalent.
  739.  
  740.      "Asking the question" means printing PROMPT in the echo area,
  741.      followed by the string `(y or n) '.  If the input is not one of
  742.      the expected answers (`y', `n', `<SPC>', `<DEL>', or something
  743.      that quits), the function responds `Please answer y or n.', and
  744.      repeats the request.
  745.  
  746.      This function does not actually use the minibuffer, since it does
  747.      not allow editing of the answer.  It actually uses the echo area
  748.      (*note The Echo Area::.), which uses the same screen space as the
  749.      minibuffer.  The cursor moves to the echo area while the question
  750.      is being asked.
  751.  
  752.      The answers and their meanings, even `y' and `n', are not
  753.      hardwired.  The keymap `query-replace-map' specifies them.  *Note
  754.      Search and Replace::.
  755.  
  756.      In the following example, the user first types `q', which is
  757.      invalid.  At the next prompt the user types `y'.
  758.  
  759.           (y-or-n-p "Do you need a lift? ")
  760.           
  761.           ;; After evaluation of the preceding expression,
  762.           ;;   the following prompt appears in the echo area:
  763.  
  764.           ---------- Echo area ----------
  765.           Do you need a lift? (y or n)
  766.           ---------- Echo area ----------
  767.           
  768.           ;; If the user then types `q', the following appears:
  769.           ---------- Echo area ----------
  770.           Please answer y or n.  Do you need a lift? (y or n)
  771.           ---------- Echo area ----------
  772.           
  773.           ;; When the user types a valid answer,
  774.           ;;   it is displayed after the question:
  775.           ---------- Echo area ----------
  776.           Do you need a lift? (y or n) y
  777.           ---------- Echo area ----------
  778.  
  779.      We show successive lines of echo area messages, but only one
  780.      actually appears on the screen at a time.
  781.  
  782.  - Function: yes-or-no-p PROMPT
  783.      This function asks the user a question, expecting input in the
  784.      minibuffer.  It returns `t' if the user enters `yes', `nil' if the
  785.      user types `no'.  The user must type <RET> to finalize the
  786.      response.  Upper and lower case are equivalent.
  787.  
  788.      `yes-or-no-p' starts by displaying PROMPT in the echo area,
  789.      followed by `(yes or no) '.  The user must type one of the
  790.      expected responses; otherwise, the function responds `Please answer
  791.      yes or no.', waits about two seconds and repeats the request.
  792.  
  793.      `yes-or-no-p' requires more work from the user than `y-or-n-p' and
  794.      is appropriate for more crucial decisions.
  795.  
  796.      Here is an example:
  797.  
  798.           (yes-or-no-p "Do you really want to remove everything? ")
  799.           
  800.           ;; After evaluation of the preceding expression,
  801.           ;;   the following prompt appears,
  802.           ;;   with an empty minibuffer:
  803.  
  804.           ---------- Buffer: minibuffer ----------
  805.           Do you really want to remove everything? (yes or no)
  806.           ---------- Buffer: minibuffer ----------
  807.  
  808.      If the user first types `y <RET>', which is invalid because this
  809.      function demands the entire word `yes', it responds by displaying
  810.      these prompts, with a brief pause between them:
  811.  
  812.           ---------- Buffer: minibuffer ----------
  813.           Please answer yes or no.
  814.           Do you really want to remove everything? (yes or no)
  815.           ---------- Buffer: minibuffer ----------
  816.  
  817.  - Function: yes-or-no-p-dialog-box PROMPT
  818.      This function asks the user a "y or n" question with a popup dialog
  819.      box.  It returns `t' if the answer is "yes".  PROMPT is the string
  820.      to display to ask the question.
  821.  
  822.    The following functions ask a question either in the minibuffer or a
  823. dialog box, depending on whether the last user event (which presumably
  824. invoked this command) was a keyboard or mouse event.  When XEmacs is
  825. running on a window system, the functions `y-or-n-p' and `yes-or-no-p'
  826. are replaced with the following functions, so that menu items bring up
  827. dialog boxes instead of minibuffer questions.
  828.  
  829.  - Function: y-or-n-p-maybe-dialog-box PROMPT
  830.      This function asks user a "y or n" question, using either a dialog
  831.      box or the minibuffer, as appropriate.
  832.  
  833.  - Function: yes-or-no-p-maybe-dialog-box PROMPT
  834.      This function asks user a "yes or no" question, using either a
  835.      dialog box or the minibuffer, as appropriate.
  836.  
  837. 
  838. File: lispref.info,  Node: Multiple Queries,  Next: Minibuffer Misc,  Prev: Yes-or-No Queries,  Up: Minibuffers
  839.  
  840. Asking Multiple Y-or-N Questions
  841. ================================
  842.  
  843.    When you have a series of similar questions to ask, such as "Do you
  844. want to save this buffer" for each buffer in turn, you should use
  845. `map-y-or-n-p' to ask the collection of questions, rather than asking
  846. each question individually.  This gives the user certain convenient
  847. facilities such as the ability to answer the whole series at once.
  848.  
  849.  - Function: map-y-or-n-p PROMPTER ACTOR LIST &optional HELP
  850.           ACTION-ALIST
  851.      This function, new in Emacs 19, asks the user a series of
  852.      questions, reading a single-character answer in the echo area for
  853.      each one.
  854.  
  855.      The value of LIST specifies the objects to ask questions about.
  856.      It should be either a list of objects or a generator function.  If
  857.      it is a function, it should expect no arguments, and should return
  858.      either the next object to ask about, or `nil' meaning stop asking
  859.      questions.
  860.  
  861.      The argument PROMPTER specifies how to ask each question.  If
  862.      PROMPTER is a string, the question text is computed like this:
  863.  
  864.           (format PROMPTER OBJECT)
  865.  
  866.      where OBJECT is the next object to ask about (as obtained from
  867.      LIST).
  868.  
  869.      If not a string, PROMPTER should be a function of one argument
  870.      (the next object to ask about) and should return the question
  871.      text.  If the value is a string, that is the question to ask the
  872.      user.  The function can also return `t' meaning do act on this
  873.      object (and don't ask the user), or `nil' meaning ignore this
  874.      object (and don't ask the user).
  875.  
  876.      The argument ACTOR says how to act on the answers that the user
  877.      gives.  It should be a function of one argument, and it is called
  878.      with each object that the user says yes for.  Its argument is
  879.      always an object obtained from LIST.
  880.  
  881.      If the argument HELP is given, it should be a list of this form:
  882.  
  883.           (SINGULAR PLURAL ACTION)
  884.  
  885.      where SINGULAR is a string containing a singular noun that
  886.      describes the objects conceptually being acted on, PLURAL is the
  887.      corresponding plural noun, and ACTION is a transitive verb
  888.      describing what ACTOR does.
  889.  
  890.      If you don't specify HELP, the default is `("object" "objects"
  891.      "act on")'.
  892.  
  893.      Each time a question is asked, the user may enter `y', `Y', or
  894.      <SPC> to act on that object; `n', `N', or <DEL> to skip that
  895.      object; `!' to act on all following objects; <ESC> or `q' to exit
  896.      (skip all following objects); `.' (period) to act on the current
  897.      object and then exit; or `C-h' to get help.  These are the same
  898.      answers that `query-replace' accepts.  The keymap
  899.      `query-replace-map' defines their meaning for `map-y-or-n-p' as
  900.      well as for `query-replace'; see *Note Search and Replace::.
  901.  
  902.      You can use ACTION-ALIST to specify additional possible answers
  903.      and what they mean.  It is an alist of elements of the form `(CHAR
  904.      FUNCTION HELP)', each of which defines one additional answer.  In
  905.      this element, CHAR is a character (the answer); FUNCTION is a
  906.      function of one argument (an object from LIST); HELP is a string.
  907.  
  908.      When the user responds with CHAR, `map-y-or-n-p' calls FUNCTION.
  909.      If it returns non-`nil', the object is considered "acted upon",
  910.      and `map-y-or-n-p' advances to the next object in LIST.  If it
  911.      returns `nil', the prompt is repeated for the same object.
  912.  
  913.      If `map-y-or-n-p' is called in a command that was invoked using the
  914.      mouse--more precisely, if `last-nonmenu-event' (*note Command Loop
  915.      Info::.) is either `nil' or a list--then it uses a dialog box or
  916.      pop-up menu to ask the question.  In this case, it does not use
  917.      keyboard input or the echo area.  You can force use of the mouse
  918.      or use of keyboard input by binding `last-nonmenu-event' to a
  919.      suitable value around the call.
  920.  
  921.      The return value of `map-y-or-n-p' is the number of objects acted
  922.      on.
  923.  
  924. 
  925. File: lispref.info,  Node: Minibuffer Misc,  Prev: Multiple Queries,  Up: Minibuffers
  926.  
  927. Minibuffer Miscellany
  928. =====================
  929.  
  930.    This section describes some basic functions and variables related to
  931. minibuffers.
  932.  
  933.  - Command: exit-minibuffer
  934.      This command exits the active minibuffer.  It is normally bound to
  935.      keys in minibuffer local keymaps.
  936.  
  937.  - Command: self-insert-and-exit
  938.      This command exits the active minibuffer after inserting the last
  939.      character typed on the keyboard (found in `last-command-char';
  940.      *note Command Loop Info::.).
  941.  
  942.  - Command: previous-history-element N
  943.      This command replaces the minibuffer contents with the value of the
  944.      Nth previous (older) history element.
  945.  
  946.  - Command: next-history-element N
  947.      This command replaces the minibuffer contents with the value of the
  948.      Nth more recent history element.
  949.  
  950.  - Command: previous-matching-history-element PATTERN
  951.      This command replaces the minibuffer contents with the value of the
  952.      previous (older) history element that matches PATTERN (a regular
  953.      expression).
  954.  
  955.  - Command: next-matching-history-element PATTERN
  956.      This command replaces the minibuffer contents with the value of
  957.      the next (newer) history element that matches PATTERN (a regular
  958.      expression).
  959.  
  960.  - Function: minibuffer-prompt
  961.      This function returns the prompt string of the currently active
  962.      minibuffer.  If no minibuffer is active, it returns `nil'.
  963.  
  964.  - Function: minibuffer-prompt-width
  965.      This function returns the display width of the prompt string of the
  966.      currently active minibuffer.  If no minibuffer is active, it
  967.      returns 0.
  968.  
  969.  - Variable: minibuffer-setup-hook
  970.      This is a normal hook that is run whenever the minibuffer is
  971.      entered.  *Note Hooks::.
  972.  
  973.  - Variable: minibuffer-exit-hook
  974.      This is a normal hook that is run whenever the minibuffer is
  975.      exited.  *Note Hooks::.
  976.  
  977.  - Variable: minibuffer-help-form
  978.      The current value of this variable is used to rebind `help-form'
  979.      locally inside the minibuffer (*note Help Functions::.).
  980.  
  981.  - Function: active-minibuffer-window
  982.      This function returns the currently active minibuffer window, or
  983.      `nil' if none is currently active.
  984.  
  985.  - Function: minibuffer-window &optional FRAME
  986.      This function returns the minibuffer window used for frame FRAME.
  987.      If FRAME is `nil', that stands for the current frame.  Note that
  988.      the minibuffer window used by a frame need not be part of that
  989.      frame--a frame that has no minibuffer of its own necessarily uses
  990.      some other frame's minibuffer window.
  991.  
  992.  - Function: window-minibuffer-p WINDOW
  993.      This function returns non-`nil' if WINDOW is a minibuffer window.
  994.  
  995.    It is not correct to determine whether a given window is a
  996. minibuffer by comparing it with the result of `(minibuffer-window)',
  997. because there can be more than one minibuffer window if there is more
  998. than one frame.
  999.  
  1000.  - Function: minibuffer-window-active-p WINDOW
  1001.      This function returns non-`nil' if WINDOW, assumed to be a
  1002.      minibuffer window, is currently active.
  1003.  
  1004.  - Variable: minibuffer-scroll-window
  1005.      If the value of this variable is non-`nil', it should be a window
  1006.      object.  When the function `scroll-other-window' is called in the
  1007.      minibuffer, it scrolls this window.
  1008.  
  1009.    Finally, some functions and variables deal with recursive minibuffers
  1010. (*note Recursive Editing::.):
  1011.  
  1012.  - Function: minibuffer-depth
  1013.      This function returns the current depth of activations of the
  1014.      minibuffer, a nonnegative integer.  If no minibuffers are active,
  1015.      it returns zero.
  1016.  
  1017.  - User Option: enable-recursive-minibuffers
  1018.      If this variable is non-`nil', you can invoke commands (such as
  1019.      `find-file') that use minibuffers even while in the minibuffer
  1020.      window.  Such invocation produces a recursive editing level for a
  1021.      new minibuffer.  The outer-level minibuffer is invisible while you
  1022.      are editing the inner one.
  1023.  
  1024.      This variable only affects invoking the minibuffer while the
  1025.      minibuffer window is selected.   If you switch windows while in the
  1026.      minibuffer, you can always invoke minibuffer commands while some
  1027.      other window is selected.
  1028.  
  1029.    In FSF Emacs 19, if a command name has a property
  1030. `enable-recursive-minibuffers' that is non-`nil', then the command can
  1031. use the minibuffer to read arguments even if it is invoked from the
  1032. minibuffer.  The minibuffer command `next-matching-history-element'
  1033. (normally `M-s' in the minibuffer) uses this feature.
  1034.  
  1035.    This is not implemented in XEmacs because it is a kludge.  If you
  1036. want to explicitly set the value of `enable-recursive-minibuffers' in
  1037. this fashion, just use an evaluated interactive spec and bind
  1038. `enable-recursive-minibuffers' while reading from the minibuffer.  See
  1039. the definition of `next-matching-history-element' in
  1040. `lisp/prim/minibuf.el'.
  1041.  
  1042. 
  1043. File: lispref.info,  Node: Command Loop,  Next: Keymaps,  Prev: Minibuffers,  Up: Top
  1044.  
  1045. Command Loop
  1046. ************
  1047.  
  1048.    When you run XEmacs, it enters the "editor command loop" almost
  1049. immediately.  This loop reads events, executes their definitions, and
  1050. displays the results.  In this chapter, we describe how these things
  1051. are done, and the subroutines that allow Lisp programs to do them.
  1052.  
  1053. * Menu:
  1054.  
  1055. * Command Overview::    How the command loop reads commands.
  1056. * Defining Commands::   Specifying how a function should read arguments.
  1057. * Interactive Call::    Calling a command, so that it will read arguments.
  1058. * Command Loop Info::   Variables set by the command loop for you to examine.
  1059. * Events::        What input looks like when you read it.
  1060. * Reading Input::       How to read input events from the keyboard or mouse.
  1061. * Waiting::             Waiting for user input or elapsed time.
  1062. * Quitting::            How `C-g' works.  How to catch or defer quitting.
  1063. * Prefix Command Arguments::    How the commands to set prefix args work.
  1064. * Recursive Editing::   Entering a recursive edit,
  1065.                           and why you usually shouldn't.
  1066. * Disabling Commands::  How the command loop handles disabled commands.
  1067. * Command History::     How the command history is set up, and how accessed.
  1068. * Keyboard Macros::     How keyboard macros are implemented.
  1069.  
  1070. 
  1071. File: lispref.info,  Node: Command Overview,  Next: Defining Commands,  Up: Command Loop
  1072.  
  1073. Command Loop Overview
  1074. =====================
  1075.  
  1076.    The command loop in XEmacs is a standard event loop, reading events
  1077. one at a time with `next-event' and handling them with
  1078. `dispatch-event'.  An event is typically a single user action, such as
  1079. a keypress, mouse movement, or menu selection; but they can also be
  1080. notifications from the window system, informing XEmacs that (for
  1081. example) part of its window was just uncovered and needs to be redrawn.
  1082. *Note Events::.  Pending events are held in a first-in, first-out list
  1083. called the "event queue": events are read from the head of the list,
  1084. and newly arriving events are added to the tail.  In this way, events
  1085. are always processed in the order in which they arrive.
  1086.  
  1087.    `dispatch-event' does most of the work of handling user actions.
  1088. The first thing it must do is put the events together into a key
  1089. sequence, which is a sequence of events that translates into a command.
  1090. It does this by consulting the active keymaps, which specify what the
  1091. valid key sequences are and how to translate them into commands.  *Note
  1092. Key Lookup::, for information on how this is done.  The result of the
  1093. translation should be a keyboard macro or an interactively callable
  1094. function.  If the key is `M-x', then it reads the name of another
  1095. command, which it then calls.  This is done by the command
  1096. `execute-extended-command' (*note Interactive Call::.).
  1097.  
  1098.    To execute a command requires first reading the arguments for it.
  1099. This is done by calling `command-execute' (*note Interactive Call::.).
  1100. For commands written in Lisp, the `interactive' specification says how
  1101. to read the arguments.  This may use the prefix argument (*note Prefix
  1102. Command Arguments::.) or may read with prompting in the minibuffer
  1103. (*note Minibuffers::.).  For example, the command `find-file' has an
  1104. `interactive' specification which says to read a file name using the
  1105. minibuffer.  The command's function body does not use the minibuffer;
  1106. if you call this command from Lisp code as a function, you must supply
  1107. the file name string as an ordinary Lisp function argument.
  1108.  
  1109.    If the command is a string or vector (i.e., a keyboard macro) then
  1110. `execute-kbd-macro' is used to execute it.  You can call this function
  1111. yourself (*note Keyboard Macros::.).
  1112.  
  1113.    To terminate the execution of a running command, type `C-g'.  This
  1114. character causes "quitting" (*note Quitting::.).
  1115.  
  1116.  - Variable: pre-command-hook
  1117.      The editor command loop runs this normal hook before each command.
  1118.      At that time, `this-command' contains the command that is about to
  1119.      run, and `last-command' describes the previous command.  *Note
  1120.      Hooks::.
  1121.  
  1122.  - Variable: post-command-hook
  1123.      The editor command loop runs this normal hook after each command.
  1124.      (In FSF Emacs, it is also run when the command loop is entered, or
  1125.      reentered after an error or quit.)  At that time, `this-command'
  1126.      describes the command that just ran, and `last-command' describes
  1127.      the command before that.  *Note Hooks::.
  1128.  
  1129.    Quitting is suppressed while running `pre-command-hook' and
  1130. `post-command-hook'.  If an error happens while executing one of these
  1131. hooks, it terminates execution of the hook, but that is all it does.
  1132.  
  1133. 
  1134. File: lispref.info,  Node: Defining Commands,  Next: Interactive Call,  Prev: Command Overview,  Up: Command Loop
  1135.  
  1136. Defining Commands
  1137. =================
  1138.  
  1139.    A Lisp function becomes a command when its body contains, at top
  1140. level, a form that calls the special form `interactive'.  This form
  1141. does nothing when actually executed, but its presence serves as a flag
  1142. to indicate that interactive calling is permitted.  Its argument
  1143. controls the reading of arguments for an interactive call.
  1144.  
  1145. * Menu:
  1146.  
  1147. * Using Interactive::     General rules for `interactive'.
  1148. * Interactive Codes::     The standard letter-codes for reading arguments
  1149.                              in various ways.
  1150. * Interactive Examples::  Examples of how to read interactive arguments.
  1151.  
  1152.